Add AssetManager.reloadAsset for development-time asset refresh#2860
Add AssetManager.reloadAsset for development-time asset refresh#2860Dingyi189-eng wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to reload assets from locators and notify listeners by adding a reloadAsset method to the AssetManager interface and a corresponding assetReloaded event to AssetEventListener. The review feedback correctly highlights that adding an abstract method to the AssetManager interface breaks backward compatibility for custom implementations, and suggests making it a default method instead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| * @throws IllegalArgumentException If the key is null or specifies no cache | ||
| * @throws AssetNotFoundException If the asset cannot be located | ||
| */ | ||
| public <T> T reloadAsset(AssetKey<T> key); |
There was a problem hiding this comment.
Adding a new abstract method to the AssetManager interface will break backward compatibility for any custom implementations of AssetManager (as they will fail to compile until they implement reloadAsset).
To maintain backward compatibility, consider making reloadAsset a default method. You can either:
- Provide a default implementation that performs the basic reload (though it won't be able to notify listeners since the interface doesn't expose them):
public default <T> T reloadAsset(AssetKey<T> key) {
if (key == null) {
throw new IllegalArgumentException("key cannot be null");
}
deleteFromCache(key);
return loadAsset(key);
}- Or simply throw an
UnsupportedOperationException:
public default <T> T reloadAsset(AssetKey<T> key) {
throw new UnsupportedOperationException("reloadAsset is not supported by this AssetManager implementation");
}
No description provided.